package cn.lingnan.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;

@Controller
@RequestMapping("admin/consumer")
public class AdminController {
    @Autowired
    private RestTemplate restTemplate;

    private String url_prefix = "http://provider-admin";


    @GetMapping("toLogin")
    public String toLogin(){
        //String uri = url_prefix + "/banji/queryAll";
        return "login";
    }

    @PostMapping("login")
    public String login(String account, String password, Model model) {

        System.out.println(account+"    "+password);
        if(account.equals("feilong")&&password.equals("shop")){
            return "index";
        }
        model.addAttribute("msg","账号或密码错误");
        //session.setAttribute("admin1",admin);
        return "login";
    }

    @GetMapping("list")
    public String list(){
        String uri = "http://consumer-goods" + "/goods/findAllGoods";
        return restTemplate.getForObject(uri,String.class);
        //return "member-list";
    }


}

